package huffmann;

public class Sort {
	public Sort(Objeto v[]){
		int i = 0,j, k = 1;
		Objeto aux;
		boolean b = true;

		while (v[i] != null)
			i++;
		
		j = i + 1;
		
		for(; j < v.length; j++){
			if (v[j] != null){
				v[i] = v[j];
				v[j] = null;
			}
		}
		
		i = 1;
		aux = v[i];
		while (aux != null){
			aux = v[i+1];
			i++;
		}
		
		j = 0;
		while(k > 0)
			k = 0;
			for (j = 0; j <= i; j++){
				if (v[j].getProbabilidade() > v[j+1].getProbabilidade()){
					aux = v[j];
					v[j] = v[j+1];
					v[j+1] = aux;
					k++;
				}
			}
	}
}
